package com.cvs.service.impl;

import com.cvs.bean.Orders;
import com.cvs.dao.OrdersMapper;
import com.cvs.service.OrdersService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("ordersService")
public class OrdersServiceImpl implements OrdersService {
    @Autowired
    private OrdersMapper ordersMapper;
    @Override
    public int insertOrder(Orders orders) {
        return ordersMapper.insertOrder(orders);
    }

    @Override
    public PageInfo<Orders> findAll(int uid, int pageNum, int pageSize,int type) {
        PageHelper.startPage(pageNum,pageSize);//设置分页状态
        Map map=new HashMap();
        map.put("uid",uid);
        map.put("type",type);
        List<Orders> orders= ordersMapper.findAll(map);
        PageInfo pageInfo=new PageInfo(orders);
        return pageInfo;
    }
}
